﻿using System.Linq.Expressions;

namespace Seagull.Foundation
{
    /// <summary>
    /// 表示
    /// <typeparamref name="TEntity"/>
    /// 对象的实体字典（序列化时会排除实体字段以外的键值对象）。
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IEntityDictionary<TEntity> : IReadOnlyCollection<KeyValuePair<string, object>> where TEntity : class
    {

        /// <summary>
        /// 替换对象的属性。
        /// </summary>
        /// <typeparam name="TProp"></typeparam>
        /// <param name="property"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        EntityDictionary<TEntity> Replace<TProp>(Expression<Func<TEntity, TProp>> property, TProp value);

        /// <summary>
        /// 替换对象的属性。
        /// </summary>
        /// <typeparam name="TProp"></typeparam>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        EntityDictionary<TEntity> Replace<TProp>(string propertyName, TProp value);

        /// <summary>
        /// 移除对象的属性。
        /// </summary>
        /// <typeparam name="TProp"></typeparam>
        /// <param name="property"></param>
        /// <returns></returns>        
        EntityDictionary<TEntity> Remove<TProp>(Expression<Func<TEntity, TProp>> property);

        /// <summary>
        /// 获取对象的属性。
        /// </summary>
        /// <typeparam name="TProp"></typeparam>
        /// <param name="property"></param>
        /// <returns></returns>
        TProp Value<TProp>(Expression<Func<TEntity, TProp>> property);
    }
}
